/**
 * 
 */
package neptune.manager.validator.rules.netif;

import neptune.manager.model.topology.NetworkInterface;
import neptune.manager.utils.Logger.MessageType;
import neptune.manager.validator.ValidatorResult;
import neptune.manager.validator.ValidatorRule;
import neptune.manager.validator.Validator.Status;

/**
 * Verifica che sia definito il mac address per l'interfaccia da convalidare
 * 
 * @author Roberto Bifulco [info@RobertoBifulco.it] [RobertoBifulco.it]
 *
 */
public class MacAddressDefinitionRule extends ValidatorRule<NetworkInterface> {

	@Override
	public String getName() {
		return "MacAddressDefinitionRule";
	}

	@Override
	protected ValidatorResult validationAlgorithm(NetworkInterface toValidate,
			ValidatorResult result) {

		if (toValidate.getMacAddress() == null
				|| toValidate.getMacAddress().getAddress() == null
				|| toValidate.getMacAddress().getAddress().equals("")) {

			result.setStatus(Status.ERROR);
			result.getLog().addMessage("No MAC address defined",
					MessageType.ERROR);

		}

		return result;
	}

}
